<%@page import="entities.Cerita"%>
<%@page import="java.util.Iterator"%>
<%@page import="entities.Komentar"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<% Cerita cerita = (Cerita) request.getAttribute("cerita_edit");%>

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cerita Unyil.com</title>
<link rel="stylesheet" type="text/css" href="style/view.css" media="all">
<script type="text/javascript" src="js/view.js"></script>

</head>
<body id="main_body" >
    
    <% List<Komentar> listkomentar = (List<Komentar>) request.getAttribute("list_komentar");%>
    <% Komentar komentar;%>
    <% Iterator<Komentar> iterator = listkomentar.iterator();%>
    <% String username = "";
        if((String) session.getAttribute("username") != null){
            username = (String) session.getAttribute("username");
        }
    %>
	
	<img id="top" src="images/top.png" alt="">
	<div id="form_container">
	
            <h1><a>Untitled Form</a></h1>
            <form id="form_318648" class="appnitro"  method="post" action="ProsesInputCerita">
                <div class="form_description">
                    <h2>Lihat Detil Cerita</h2>
                    <p>Detil judul dan isi cerita beserta komentar disini.</p>
                    <p><a href="cerita?propinsi=<%=cerita.getPropinsi().getId()%>">Kembali</a></p>
		</div>						
                <ul>			
                    <li id="li_1" >
                        <label class="description" for="judul_cerita">Judul </label>
                        <div>
                            <input id="element_1" readonly="readonly" name="judul_cerita" class="element text medium" type="text" maxlength="255" value="<%=cerita.getJudul_cerita()%>"/> 
                        </div> 
                    </li>		
                    <li id="li_2" >
                        <label class="description" for="isi_cerita">Isi Cerita </label>
                        <div>
                            <textarea id="element_2" readonly="readonly" name="isi_cerita" class="element textarea large"><%=cerita.getIsi_cerita()%></textarea> 
                    </div> 
                    </li>
                </ul>
                    
                <ul>
                    <li>
                   
                        <h2>Komentar Cerita</h2>
                        
                        <% if(!username.equals("")){ %>
                            <a href="InputKomentar?cerita=<%=cerita.getId()%>">Tambah Komentar</a>   
                        <%;}%>
                    </li>
                    
                </ul>
                    
                <% while (iterator.hasNext()) {
                komentar = iterator.next();%>
                    <ul>
                        <li>
                            ---------------------------------------------------------------------
                        </li>
                    </ul>
                    <ul>			
                        <li>
                            <label class="description" for="username">Pemberi komentar</label>       
                            <div>
                                <input name="username" class="element text medium" type="text" maxlength="255" value="<%=komentar.getUsers().getUsername()%>"/>   
                            </div> 
                            
                        </li>		
                        <li>
                            <label class="description" for="isi_komentar">
                                Komentar                            
                                <% if(username.equals("admin")){%>
                                    <a href="EditKomentar?komentar=<%=komentar.getId()%>">edit</a> 
                                    <a href="ProsesDeleteKomentar?komentar=<%=komentar.getId()%>">delete</a>
                                <%;}%>
                            </label>
                            <div>
                                <textarea name="isi_cerita" class="element textarea small"><%=komentar.getIsi_komentar()%></textarea> 
                        </div> 
                        </li>
                    </ul>                        
                <%}%>    
                        
            </form>	
     
            <div id="footer">
                Generated by <a href="http://www.phpform.org">pForm</a>
            </div>
	</div>
	<img id="bottom" src="images/bottom.png" alt="">     
</body>
</html>